package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * projectName: com.atguigu.lease.common.minio
 *
 * @author: 赵伟风
 * description: 配置minioClient
 */


@Configuration
@EnableConfigurationProperties(MinioProperties.class) //加入到ioc容器
public class MinioConfiguration {

    @Autowired
    private MinioProperties minioProperties;


    @Bean
    public MinioClient minioClient(){
        //构造MinIO Client
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                .credentials(minioProperties.getAccessKey(),
                        minioProperties.getSecretKey())
                .build();
        return minioClient;
    }

}
